package chat.components;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

import network.ChannelData;


@SuppressWarnings({ "serial", "rawtypes" })
public class ChannelCellRenderer extends JLabel implements ListCellRenderer {
	@Override
	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {

		ChannelData channel = (ChannelData)value;
	
		this.setText(channel.name + " (" + channel.userCount + ")" );

		this.setOpaque(true);
		if(isSelected){
			this.setForeground(Color.WHITE);  
			this.setBackground(Color.BLACK);
		}
		else{
			this.setForeground(Color.BLACK);
			this.setBackground(Color.WHITE);
		}

		return this;
	}
}
